
	class Card {
		
		String suit;
		int rank;
		
		public Card(String st, int rk){
			this.suit = st;
			this.rank = rk;
		}
		
		public String getSuit(){
			return this.suit;
		}
		
		public int getRank(){
			return this.rank;
		}
		
		
		
		
		public static void sortCards(Card[] input){
			int i = 0;
		while(i <= input.length - 1){
			
			if(input[i].getSuit() == "spade"){
				if (input[i + 1].getSuit() != "spade" || input[i].getRank() > input[i+1].getRank()){
					switchCards(input[i],input[i+1]);
					System.out.println(input[i].getSuit() + " " + input[i].getRank());
				}
			

				}
			else if (input[i].getSuit() == "heart"){
				while(i > 0 && input[i-1].getSuit() == "spade" || (input[i=1].getSuit() == "heart" && input[i-1].getRank() < input[i].getRank())){
					switchCards(input[i-1],input[1]);
					System.out.println(input[i].getSuit() + " " + input[i].getRank());
				}
				
				while(i <= input.length - 1 && input[i+1].getSuit() != "spade" || (input[i+1].getSuit() == "heart" && input[i+1].getRank() <= input[i].getRank())){
					switchCards(input[i],input[i+1]);
					System.out.println(input[i].getSuit() + " " + input[i].getRank());
				}
				
				}
			}
		}
		
		
		
		
		public static void switchCards(Card card1,Card card2){
			Card temp = new Card("",0);
			temp.suit = card2.getSuit();
			temp.rank = card2.getRank();
			card2.suit = card1.getSuit();
			card2.rank = card1.getRank();
			card1.suit = temp.getSuit();
			card1.rank = temp.getRank();
		}
		

}
